package com.itheima.HomeWork_day10;

import java.util.HashMap;
import java.util.Set;

public class HashMapTest04 {
    public static void main(String[] args) {
        //创建HashMap集合对象
        HashMap<Student, String> hm = new HashMap<Student, String>();

        //创建学生对象
        Student s1 = new Student("林青霞", 30);
        Student s2 = new Student("张曼玉", 35);
        Student s3 = new Student("王祖贤", 33);
        Student s4 = new Student("王祖贤", 33);

        //将学生对象添加到集合中
        hm.put(s1,"上海");
        hm.put(s2,"广东");
        hm.put(s3,"四川");
        hm.put(s4,"山东");

        //遍历集合
        Set<Student> st = hm.keySet();
        for (Student key : st) {
            String value = hm.get(key);
           // System.out.println(key+"--"+value);
            System.out.println(key.getName() + "," + key.getAge() + "," + value);
        }


    }
}
